package com.cqfae.deploycentral.app.web.controller;

import com.cqfae.deploycentral.app.utils.GsonUtils;
import com.cqfae.deploycentral.app.services.CommonControllerService;
import com.cqfae.deploycentral.app.services.DatePlateService;
import com.cqfae.deploycentral.app.services.JiraService;
import com.cqfae.deploycentral.app.utils.NullUtil;
import com.cqfae.deploycentral.app.web.response.WebResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/deploy-central/dataPlate")
public class DataPlateCentralController implements CommonControllerService<Object> {

    @Autowired
    private JiraService jiraService;

    @Autowired
    private DatePlateService datePlateService;

    /**
     * 开发查询所有地图数据
     * @return WebResponse
     */
    @RequestMapping(value = "/info")
    public WebResponse pageInfo() {
        return getWebResponse(datePlateService.displayDeployCentral());
    }

    /**
     * 数据大盘
     * @return
     */
    @RequestMapping(value = "/display")
    public WebResponse display() {
        return getWebResponse(GsonUtils.getInstance().toJson(datePlateService.displayDatePlateVo()));
    }

    @Override
    public WebResponse getWebResponse(Object obj) {
        WebResponse webResponse = new WebResponse();
        if (NullUtil.isNotEmpty(obj)) {
            webResponse.setData(obj);
        }
        return webResponse;
    }
}
